package com.focusai.efairy.ui.adapter.report;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.focusai.efairy.R;
import com.focusai.efairy.model.report.AnalyseDataType;
import com.focusai.efairy.ui.widget.WaveProgressView;
import com.focusai.efairy.utils.ScreenUtil;

import me.drakeet.multitype.ItemViewBinder;

/**
 * Created by luo_guangwen on 2017/8/1.
 */

public class ReportWavaAnalyseViewBinder extends ItemViewBinder<AnalyseDataType, ReportWavaAnalyseViewBinder.ViewHolder> {
    //报表饼图的色值
    private int[] colors;
    private Context mContext;
    public ReportWavaAnalyseViewBinder(Context context) {
        this.mContext = context;
    }

    @NonNull
    @Override
    protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View root = inflater.inflate(R.layout.item_report_analyze, parent, false);
        ViewHolder viewHolder = new ViewHolder(root);
        return viewHolder;
    }

    @Override
    protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull AnalyseDataType item) {
        if (item.safely_points > 50){
            holder.waveProgressView.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.progress_green_circle));
            holder.waveProgressView.setWaveColor(mContext.getResources().getColor(R.color.wava_deep_green));
            holder.waveProgressView.setText(mContext.getResources().getColor(R.color.white), ScreenUtil.dp2pix(40));
        }else {
            holder.waveProgressView.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.progress_orange_circle));
            holder.waveProgressView.setWaveColor(mContext.getResources().getColor(R.color.wava_deep_orange));
            holder.waveProgressView.setText(mContext.getResources().getColor(R.color.white), ScreenUtil.dp2pix(40));
        }
        holder.waveProgressView.setCurrent(item.safely_points,item.safely_points+"");
    }

    static class ViewHolder extends RecyclerView.ViewHolder {

        WaveProgressView waveProgressView;
        ViewHolder(View itemView) {
            super(itemView);
            waveProgressView = (WaveProgressView) itemView.findViewById(R.id.wava_progress_view);
        }

    }
}
